package si.yun.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import si.yun.common.ConstantEntity;
import si.yun.dao.PersonnelDao;
import si.yun.dao.SyForumMapper;
import si.yun.dao.SyUserMapper;
import si.yun.entity.*;
import si.yun.service.PersonnelService;
import si.yun.utils.TestAliUpload;

import java.util.*;

/**
 * @program: SiYunClass
 * @description: 人事业务层
 * @author: 崔晓晨
 * @create: 2021-07-28 20:50
 **/
@Service
public class PersonnelServiceImpl implements PersonnelService {
    @Autowired
    private PersonnelDao personnelDao;
    @Autowired
    private SyUserMapper syUserMapper;

    @Autowired
    private si.yun.dao.SyProductMapper SyProductMapper;
    @Autowired
    private SyForumMapper dao;


    @Autowired
    public TestAliUpload testAliUpload;

    /**
     * @Description  查询用户的数据展示
     * @return si.yun.entity.PerCount
     * @Date 2021/7/29 14:19
     **/
    @Override
    public PerCount selUserNum() {
        PerCount p = new PerCount();
        int today = personnelDao.selUserToday();
        int yes = personnelDao.selUserYes();
        int mou = personnelDao.selUserMou();
        int Num = personnelDao.selUserNum();
        int passNum = personnelDao.selapplyPassNum();
        int afterUserNum = personnelDao.selAfterUserNum();
        int fee = personnelDao.selFeedBackWaitNum();
        int waitNum = personnelDao.selApplyWaitNum();
        p.setUserMou(mou);
        p.setUserNum(Num);
        p.setUserYes(yes);
        p.setUserToday(today);
        p.setAfterUserNum(afterUserNum);
        p.setApplyPassNum(passNum);
        p.setFeedbackWaitNum(fee);
        p.setApplyWaitNum(waitNum);
        return p;
    }
    /**
     * @Description  获取期间内申请人员统计信息
     * @return si.yun.entity.PerCount
     * @Date 2021/7/28 21:32
     **/
    @Override
    public PerCount selPerTab(int durDate) {
        int perCount = personnelDao.selApplyNum();
        int perPass = personnelDao.selApplyPass(durDate);
        int applyRejection = personnelDao.selApplyRejection(durDate);
        String applyPosition = personnelDao.selApplyPosition(durDate);
        PerCount p = new PerCount();
        p.setApplyNum(perCount);
        p.setApplyPass(perPass);
        p.setApplyRejection(applyRejection);
        p.setApplyPosition(applyPosition);
        return p;
    }
    /**
     * @Description 获取用户统计量
     * @return list<Integer>
     * @Date 2021/7/29 13:28
     **/
    @Override
    public List<Integer> selUserEcharts() {
        int day1 = personnelDao.selUserday1();
        int day2 = personnelDao.selUserday2();
        int day3 = personnelDao.selUserday3();
        int day4 = personnelDao.selUserday4();
        int day5 = personnelDao.selUserday5();
        int day6 = personnelDao.selUserday6();
        int day7 = personnelDao.selUserday7();
        List<Integer> list = new ArrayList<>();
        list.add(day1);
        list.add(day2);
        list.add(day3);
        list.add(day4);
        list.add(day5);
        list.add(day6);
        list.add(day7);
        return list;
    }
    /**
     * @Description  获取用户列表
     * @return java.util.List<si.yun.entity.SyBeforeUser>
     * @Date 2021/7/29 19:22
     **/
    @Override
    public List<SyBeforeUser> selUserTable(SyBeforeUser beforeUser) {
        List<SyBeforeUser> beforeUsers = personnelDao.selUserTable(beforeUser);
        return beforeUsers;
    }

    /**
     * @Description  添加停用的用户
     * @return int
     * @Date 2021/8/1 18:37
     **/
    @Transactional
    @Override
    public int addClosure(SyClosure closure) {
        int add = personnelDao.addClosure(closure);
        updBeforeStatus(closure.getUserId(),3);
        return add;
    }
    /**
     * @Description  查询单个用户的详细信息
     * @return si.yun.entity.SyBeforeUser
     * @Date 2021/8/1 19:00
     **/
    @Override
    public SyBeforeUserVo selUserInfo(int userId) {
        SyBeforeUserVo beforeUser = personnelDao.selBefoUserInfoId(userId);

        //用户观看视频
        int videoNum = personnelDao.selUserVideo(beforeUser.getUserId());
        beforeUser.setVideoNum(videoNum);

        //用户收藏
        int collection = personnelDao.selUserCollection(beforeUser.getUserId());
        beforeUser.setCollection(collection);

        //用户点赞
        int like = personnelDao.selUserLike(beforeUser.getUserId());
        beforeUser.setLike(like);
        return beforeUser;
    }
    /**
     * @Description  查询单个后台用户的详细信息
     * @return si.yun.entity.SyUser
     * @Date 2021/8/21 10:41
     **/
    @Override
    public SyUser selBackUserInfo(int userId) {
        SyUser syUser = personnelDao.selBackUserInfo(userId);
        return syUser;
    }
    /**·
     * @Description  编译用户信息 ( 不能编译用户的学习时长  和 交易金额 以及 账号创建时间)
     * @return int
     * @Date 2021/8/1 21:00
     **/
    @Override
    public int updSelUser(SyBeforeUser beforeUser) {
        int upd = personnelDao.updSelUser(beforeUser);
        return upd;
    }
    /**
     * @Description  查询封号用户列表
     * @return java.util.List<si.yun.entity.SyClosure>
     * @Date 2021/8/2 9:43
     **/
    @Override
    public List<SyClosure> selClosureUserTable(SyClosure closure) {
        List<SyClosure> closures = personnelDao.selClosureUserTable(closure);
        return closures;
    }
    /**
     * @Description  解封用户 改变封号列表信息
     * @return int
     * @Date 2021/8/2 15:12
     **/
    @Override
    @Transactional
    public int updClosure(SyClosure closure) {
        String reason = closure.getReason();
        closure.setReason(reason+"(已解封)");
        int upd = personnelDao.updClosure(closure);
        int userId = closure.getUserId();
        int type = closure.getType();
        if(type==2){
            int status = 2;
            updBeforeStatus(userId,status);
        }else if(type==3){
            int status = 1;
            updBackUserStatus(userId,status);
        }
        return upd;
    }
    /**
     * @Description  更改用户账号的状态
     * @return int
     * @Date 2021/7/30 14:37
     **/
    public int updBeforeStatus(int userId,int status) {
        int upd = personnelDao.updBeforeStatus(userId,status);
        return upd;
    }
    public int updBackUserStatus(int userId,int status){
        int upd = personnelDao.updBackStatus(userId, status);
        return  upd;
    }
    /**
     * @Description  删除停用后的封停日志
     * @return int
     * @Date 2021/7/30 15:39
     **/
    @Override
    public int delBeforeStatus(int id) {
        int del = personnelDao.delBeforeStatus(id);
        return del;
    }
    /**
     * @Description  查询进思用户列表的详细数据
     * @return java.util.List<si.yun.entity.PerUserListThink>
     * @Date 2021/8/3 10:07
     **/
    @Override
    public List<PerUserListThink> selThinkUserTable(PerUserListThink userThink) {
        List<PerUserListThink> list =  personnelDao.selThinkUserTable(userThink);
        return list;
    }
    /**
     * @Description  查看进思用户的详细信息
     * @return si.yun.entity.SyUserDevelopment
     * @Date 2021/8/3 20:53
     **/
    @Override
    public PerUserListThink selUserThinkIndex(int developmentId) {
        PerUserListThink development = personnelDao.selUserThinkIndex(developmentId);
        return development;
    }
    /**
     * @Description  上传图片文件 更换头像
     * @return int
     * @Date 2021/8/4 19:49
     **/
    @Override
    public int updImg(int developmentId, String newName, int userId) {
        int upd = personnelDao.updImg(developmentId,newName,userId);
        return upd;
    }
    /**
     * @Description  编译进思用户的基本信息
     * @return int
     * @Date 2021/8/5 9:31
     **/
    @Override
    public int updThinkInfo(PerUserListThink perUserListThink) {
        int upd = personnelDao.updThinkInfo(perUserListThink);
        return upd;
    }
    /**
     * @Description  查询优惠券列表
     * @return java.util.List<si.yun.entity.OperCoupons>
     * @Date 2021/8/5 10:56
     **/
    @Override
    public List<OperCoupons> selAwayListTab() {
        List<OperCoupons> list = personnelDao.selAwayListTab();
        return list;
    }
    /**
     * @Description  添加 赠送优惠券的优惠券记录
     * @return int
     * @Date 2021/8/5 14:14
     **/
    @Transactional
    @Override
    public int addUserCoupons(List<Integer> userId, List<Integer> couponId) {
        int add = personnelDao.addUserCoupons(userId,couponId);
        selGaveNum();
        return add;
    }
    public List<SyUserCoupon> selGaveNum(){
        List<SyUserCoupon> operCoupons = personnelDao.selGaveNum();
        updSurplus(operCoupons);
        return operCoupons;
    }
    public int updSurplus(List<SyUserCoupon> operCoupons){
        int upd = personnelDao.updSurplus(operCoupons);
        return upd;
    }
    /**
     * @Description  添加进思用户列表
     * @return int
     * @Date 2021/8/6 11:07
     **/
    @Override
    public int addThinkUserInfo(SyUserDevelopment development) {
        int add = personnelDao.addThinkUserInfo(development);
        return add;
    }
    /**
     * @Description  添加后端操作日志
     * @return int
     * @Date 2021/8/6 14:10
     **/
    @Override
    public int addOperationLog(SyOperationLog log) {
        int add = personnelDao.addOperationLog(log);
        return add;
    }
    /**
     * @Description  添加封号操作日志
     * @return int
     * @Date 2021/8/6 16:22
     **/
    @Override
    public int addClosureLog(SyClosureLog syClosureLog) {
        int add = personnelDao.addClosureLog(syClosureLog);
        return add;
    }
    /**
     * @Description  查询封号日志表
     * @return java.util.List<si.yun.entity.PerClosureLog>
     * @Date 2021/8/6 17:24
     **/
    @Override
    public List<PerClosureLog> selClosureLog(PerClosureLog log) {
        List<PerClosureLog> perClosureLogs = personnelDao.selClosureLog(log);
        return perClosureLogs;
    }
    /**
     * @Description  删除封号日志
     * @return int
     * @Date 2021/8/9 9:12
     **/
    @Override
    public int delClosureLog(int id) {
        int del = personnelDao.delClosureLog(id);
        return del;
    }
    /**
     * @Description  查看操作日志数据
     * @return java.util.List<si.yun.entity.SyOperationLog>
     * @Date 2021/8/10 8:48
     **/
    @Override
    public List<SyOperationLog> selOperationLog(SyOperationLog operationLog) {
        List<SyOperationLog> syOperationLogs = personnelDao.selOperationLog(operationLog);
        return syOperationLogs;
    }
    /**
     * @Description  删除操作日志
     * @return int
     * @Date 2021/8/10 9:17
     **/
    @Override
    public int delOperationLog(int id) {
        int del = personnelDao.delOperationLog(id);
        return del;
    }
    /**
     * @Description  获取非进思用户列表
     * @return java.util.List<si.yun.entity.SyBeforeUser>
     * @Date 2021/8/10 10:01
     **/
    @Override
    public List<SyBeforeUser> selNotThinkUser(SyBeforeUser beforeUser) {
        List<SyBeforeUser> beforeUsers = personnelDao.selNotThinkUser(beforeUser);
        return beforeUsers;
    }
    /**
     * @Description  查看前台用户反馈列表
     * @return java.util.List<si.yun.entity.PerFeedback>
     * @Date 2021/8/10 16:59
     **/
    @Override
    public List<PerFeedback> selFeedbackList(PerFeedback feedback) {
        List<PerFeedback> feedbacks = personnelDao.selFeedbackList(feedback);
        return feedbacks;
    }
    /**
     * @Description  查询待审核 已受理的数量（反馈列表）
     * @return si.yun.entity.PerFeedback
     * @Date 2021/8/12 19:42
     **/
    @Override
    public PerFeedback selAduFeedNum() {
        PerFeedback feedback = new PerFeedback();
        int waitNum = personnelDao.selWaitNum();
        int acceptedNum = personnelDao.selAcceptedNum();
        feedback.setWaitNum(waitNum);
        feedback.setAcceptedNum(acceptedNum);
        return feedback;
    }
    /**
     * @Description  更新已受理状态
     * @return int
     * @Date 2021/8/13 9:00
     **/
    @Override
    public int updFeedback(Integer feedbackStatus,Integer feedbackId) {
        int upd = personnelDao.updFeedback(feedbackStatus,feedbackId);
        return upd;
    }
    /**
     * @Description  查看受理详情
     * @return si.yun.entity.PerOperationLog
     * @Date 2021/8/13 10:50
     **/
    @Override
    public PerOperationLog selReceiveInfo(String tablename, String remark) {
        PerOperationLog perOperationLog = personnelDao.selReceiveInfo(tablename, remark);
        return perOperationLog;
    }
    /**
     * @Description  删除反馈信息
     * @return int
     * @Date 2021/8/13 11:30
     **/
    @Override
    public int delFeedback(Integer feedbackId) {
        int del = personnelDao.delFeedback(feedbackId);
        return del;
    }
    /**
     * @Description  查询无消费记录用户列表
     * @return java.util.List<si.yun.entity.SyBeforeUser>
     * @Date 2021/8/13 16:59
     **/
    @Override
    public List<SyBeforeUser> selNotSpendUser(SyBeforeUser beforeUser) {
        List<SyBeforeUser> beforeUsers = personnelDao.selNotSpendUser(beforeUser);
        return beforeUsers;
    }
    /**
     * @Description  查询部门数据管理列表
     * @return java.util.List<si.yun.entity.PerDept> 
     * @Date 2021/8/14 9:46
     **/
    @Override
    public List<PerDept> selDeptList(PerDept dept) {
        List<PerDept> perDepts = personnelDao.selDeptList(dept);
        return perDepts;
    }
    /**
     * @Description  更新部门启用 停用状态
     * @return int
     * @Date 2021/8/14 15:00
     **/
    @Override
    public int updDeptStatus(Integer deptId, Integer deptStatus) {
        int upd = personnelDao.updDeptStatus(deptId,deptStatus);
        return upd;
    }
    /**
     * @Description  修改部门信息
     * @return int
     * @Date 2021/8/15 9:27
     **/
    @Override
    public int updDeptInfo(SyDept dept) {
        int upd = personnelDao.updDeptInfo(dept);
        return upd;
    }
    /**
     * @Description  添加部门
     * @return int
     * @Date 2021/8/15 10:25
     **/
    @Override
    public int addDeptInfo(PerDept dept) {
        int add = personnelDao.addDeptInfo(dept);
        return add;
    }
    /**
     * @Description  删除部门信息
     * @return int
     * @Date 2021/8/15 14:05
     **/
    @Override
    public int delDeptInfo(Integer deptId) {
        int del = personnelDao.delDeptInfo(deptId);
        return del;
    }
    /**
     * @Description  获取部门信息（树形）
     * @return java.util.List<si.yun.entity.PerDeptZtreeNode> 
     * @Date 2021/8/16 19:01
     **/
    @Override
    public List<PerDeptZtreeNode> selDeptName() {
        List<PerDeptZtreeNode> deptName = personnelDao.selDeptName();
        return deptName;
    }
    /**
     * @Description  获取后台管理员信息
     * @return java.util.List<si.yun.entity.SyUser> 
     * @Date 2021/8/16 20:21
     **/
    @Override
    public List<PerBackUser> selBackUserList(PerBackUser user) {
        List<PerBackUser> syUsers = personnelDao.selBackUserList(user);
        return syUsers;
    }
    /**
     * @Description  管理后台管理员账号的账户是否启用
     * @return int
     * @Date 2021/8/17 15:45
     **/
    @Override
    public int updBackUserEnabled(Integer userId, Integer enabled) {
        int upd = personnelDao.updBackUserEnabled(userId,enabled);
        return upd;
    }
    /**
     * @Description  查找所有封停用户
     * @return java.util.List<si.yun.entity.PerClosureUser>
     * @Date 2021/8/20 21:02
     **/
    @Override
    public List<PerClosureUser> selClosureUser() {
        List<PerClosureUser> perClosureUsers = personnelDao.selClosureUser();
        return perClosureUsers;
    }
    /**
     * @Description  更改用户账号状态   封停用户账号
     * @return int
     * @Date 2021/8/21 9:54
     **/
    @Override
    public int updBackUserStatus(Integer userId, Integer enabled, Integer status) {
        int upd = personnelDao.updBackUserStatus(userId, enabled, status);
        return upd;
    }
    /**
     * @Description  更新后台管理员信息
     * @return int
     * @Date 2021/8/25 10:12
     **/
    @Override
    public int updBackUserInfo(PerBackUser user) {
        int upd = personnelDao.updBackUserInfo(user);
        return upd;
    }
    /**
     * @Description  更新后台管理员头像
     * @return int
     * @Date 2021/8/25 15:36
     **/
    @Override
    public int updBackUserImg(String newName, int userId) {

        //删除服务器图片
        testAliUpload.delete( syUserMapper.getUserUrl(userId));

        //修改图片
        int upd = personnelDao.updBackUserImg(newName,userId);
        return upd;
    }
    /**
     * @Description  导入后台管理员
     * @return int
     * @Date 2021/8/27 20:07
     **/
    @Override
    public int importExcelUser(List<PerBackUser> syUsers) {
        int add = personnelDao.importExcelUser(syUsers);
        return add;
    }
    /**
     * @Description  添加后台管理人员
     * @return int
     * @Date 2021/9/4 17:30
     **/
    @Override
    public int addBackUserInfo(PerBackUser backUser) {
        int add = personnelDao.addBackUserInfo(backUser);
        return add;
    }
    /**
     * @Description 获取今年每月新增的用户数量（用户）
     * @return java.util.List<si.yun.entity.UserMonth>
     * @Date 2021/9/9 18:32
     **/
    @Override
    public List<Integer> selBeforeNum() {
        UserMonth beforeUserNum = personnelDao.selBeforeNum();
        List<Integer> before = setList(beforeUserNum);
        return before;
    }
    /**
     * @Description 获取今年每月新增的用户数量（后端）
     * @return java.util.List<si.yun.entity.UserMonth>
     * @Date 2021/9/9 18:32
     **/
    @Override
    public List<Integer> selBackNum() {
        UserMonth backUserNum = personnelDao.selBackNum();
        List<Integer> back = setList(backUserNum);
        return back;
    }
    public List<Integer> setList(UserMonth userNum){
        List<Integer> list = new ArrayList<>();
        list.add(userNum.getJanuary());
        list.add(userNum.getFebruary());
        list.add(userNum.getMarch());
        list.add(userNum.getApril());
        list.add(userNum.getMay());
        list.add(userNum.getJune());
        list.add(userNum.getJuly());
        list.add(userNum.getAugust());
        list.add(userNum.getSeptember());
        list.add(userNum.getOctober());
        list.add(userNum.getNovember());
        list.add(userNum.getDecember());
        return list;
    }
    /**
     * @Description 获取人员登录总次数 成功次数（前端 ，管理端）
     * @return si.yun.entity.UserMonth
     * @Date 2021/9/10 9:47
     **/
    @Override
    public UserMonth selLoginNums() {
        UserMonth user = new UserMonth();
        Integer before = personnelDao.selBeforeLoginNum();
        Integer back = personnelDao.selBackLoginNum();
        user.setBackLoginNum(back);
        user.setBeforeLoginNum(before);
        return user;
    }
    /**
     * @Description  获取某一时间段内登录的数据(前)
     * @return java.util.List<java.lang.Integer> 
     * @Date 2021/9/10 9:11
     **/
    @Override
    public List<Integer> getLoginTime() {
        List<Integer> list = new ArrayList<>();
        Integer one = personnelDao.selTimeOne();
        Integer two = personnelDao.selTimeTwo();
        Integer three = personnelDao.selTimeThree();
        Integer fore = personnelDao.selTimeFore();
        Integer five = personnelDao.selTimeFive();
        list.add(one);
        list.add(two);
        list.add(three);
        list.add(fore);
        list.add(five);
        return list;
    }
    /**
     * @Description  获取某一时间段内登录的数据(管)
     * @return java.util.List<java.lang.Integer>
     * @Date 2021/9/10 9:11
     **/
    @Override
    public List<Integer> getLoginTimes() {
        List<Integer> list = new ArrayList<>();
        Integer one = personnelDao.selTimeOnes();
        Integer two = personnelDao.selTimeTwos();
        Integer three = personnelDao.selTimeThrees();
        Integer fore = personnelDao.selTimeFores();
        Integer five = personnelDao.selTimeFives();
        list.add(one);
        list.add(two);
        list.add(three);
        list.add(fore);
        list.add(five);
        return list;
    }
    /**
     * @Description  查询不同的反馈类型下不同的反馈结果数据
     * @return si.yun.entity.PerFeedData
     * @Date 2021/9/10 14:13
     **/
    @Override
    public PerFeedData selFeedDatas(Integer feedbackType) {
        PerFeedData perFeedData = personnelDao.selFeedDatas(feedbackType);
        return perFeedData;
    }
    /**
     * @Description  查询反馈的总数
     * @return si.yun.entity.PerFeedData
     * @Date 2021/9/10 14:14
     **/
    @Override
    public PerFeedData selFeedBackNums() {
        PerFeedData perFeedData = personnelDao.selFeedBackNums();
        return perFeedData;
    }
    /**
     * @Description  查询不同类型下的课程视频播放量
     * @return java.util.List<si.yun.entity.PerCourseLook> 
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<PerCourseLook> selCourseLookNum() {
        List<PerCourseLook> perCourseLooks = personnelDao.selCourseLookNum();
        return perCourseLooks;
    }
    /**
     * @Description  查询审核列表数据
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String,Object>> selAuditList(Map<String ,Object> m) {
        List<Map<String,Object>> perCourseLooks = personnelDao.selAuditList(m);
        return perCourseLooks;
    }
    /**
     * @Description  审核列表数据通过
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    @Transactional
    public int updAuditUser(Map<String ,Object> m) {
        int i=personnelDao.updAuditUser1(ConstantEntity.TWO,m);

        int i1 = updAuditUser1(m);

        Map<String ,Object> map=new HashMap<>();
        map.put("from_id",m.get("implementId"));
        map.put("to_id",m.get("user_id"));
        map.put("content","你的创作申请已通过，您现在已拥有创作者特权");
        int i2 = upConversotion2(map);
        
        if(i==0 || i1==0 || i2==0){
            throw new RuntimeException();
        }
        int sum=i+i1+i2;

        return sum;
    }
    
    /*
     * @Description : 审核列表数据通过
     * @Return : int
     * @Date : 2021/12/27 9:20
     */
    @Transactional
    public int updAuditUser1(Map<String ,Object> m){
        int i = personnelDao.updAuditUser(m);
        return i;
    }
    
    /*
     * @Description : 审核列表通过返回
     * @Return : int
     * @Date : 2021/12/27 9:19
     */
    @Transactional
    public int upConversotion2(Map<String ,Object> m){
        int i = personnelDao.upConversotion(m);
        return i;
    }

    /**
     * @Description  审核列表数据删除
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public int delAuditUser(Map<String, Object> m) {
        int i=personnelDao.delAuditUser(ConstantEntity.THREE,m);

        int i1 = updAuditUser1(m);

        Map<String ,Object> map=new HashMap<>();
        map.put("from_id",m.get("implementId"));
        map.put("to_id",m.get("user_id"));
        map.put("content","你的创作申请已被驳回，更正审核信息后可重新申请");
        int i2 = upConversotion2(map);

        if(i==0 || i1==0 || i2==0){
            throw new RuntimeException();
        }
        int sum=i+i1+i2;
        return sum;
    }
    /**
     * @author: DZQ
     * @description: 审核列表通过驳回返回
     * @date: 2021/12/2 9:59
     * @return
     */
    @Override
    public int upConversotion(Map<String, Object> m) {
        return personnelDao.upConversotion(m);
    }




    /**
     * @Description  审核列表数据查看详情
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public Map<String, Object> selAuditUser(String id) {
        return personnelDao.selAuditUser(id);
    }
    /**
     * @Description  前台用户登录日志
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String, Object>> selReceptionLoginLog(Map<String, Object> m) {
        return personnelDao.selReceptionLoginLog(m);
    }
    /**
     * @Description  删除前台用户登录日志
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public int delReceptionLoginLog(String id) {
        return personnelDao.delReceptionLoginLog(id);
    }

    /**
     * @Description  后台用户登录日志
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String, Object>> selBackstageLoginLog(Map<String, Object> m) {
        return personnelDao.selBackstageLoginLog(m);
    }
    /**
     * @Description  查询不同类型下的课程视频收藏量
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String,Object>> selCourseCollection() {
        List<Map<String,Object>> perCourseLooks = personnelDao.selCourseCollection();
        return perCourseLooks;
    }
    /**
     * @Description  查询不同类型下的课程视频点赞量
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String,Object>> selCoursePraise() {
        List<Map<String,Object>> perCourseLooks = personnelDao.selCoursePraise();
        return perCourseLooks;
    }
    /**
     * @Description  查询不同类型下的微圈收藏量统计
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String, Object>> selMicrocircleCollection() {
        List<Map<String,Object>> perCourseLooks = personnelDao.selMicrocircleCollection();
        return perCourseLooks;
    }

    /**
     * @Description  查询不同类型下的微圈点赞量统计
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String, Object>> selMicroCirclePraise() {
        List<Map<String,Object>> perCourseLooks = personnelDao.selMicroCirclePraise();
        return perCourseLooks;
    }
    /**
     * @Description  查询不同类型下的微圈预览量统计
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String, Object>> selMicrocirclePreview() {
        List<Map<String,Object>> perCourseLooks = personnelDao.selMicrocirclePreview();
        return perCourseLooks;
    }
    /**
     * @Description  查询不同类型下的微圈商品收藏量统计
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String, Object>> selCommodityCollection() {
        List<Map<String,Object>> perCourseLooks = personnelDao.selCommodityCollection();
        return perCourseLooks;
    }
    /**
     * @Description  查询不同类型下的商品点赞量统计
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String, Object>> selProductLikes() {
        List<Map<String,Object>> perCourseLooks = personnelDao.selProductLikes();
        return perCourseLooks;
    }
    /**
     * @Description  查询不同类型下的商品订单量统计
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String, Object>> selCommodityOrder(double money) {
        List<Map<String,Object>> perCourseLooks = personnelDao.selCommodityOrder(money);
        return perCourseLooks;
    }
    /**
     * @Description  权限
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public Map<String, Object> selJurisdiction(Integer userId) {
        Map<String,Object> map=new HashMap<>();
        //所有权限
        List<Map<String, Object>> list= personnelDao.selJurisdictionList();
        //获取该用户权限
        Map<String, Object> list1=personnelDao.selJurisdiction(userId);
        String account = (String) list1.get("account");
        //创建一个集合用来存储该用户相对应得权限
        Set<String> set=new HashSet<>();
        //获取该用户相对用的角色权限
        Set<String> getRole=syUserMapper.getUserAuthority(account);
        //获取后台部门相对应的权限
        Set<String> deptAuthority = syUserMapper.getDeptAuthority(account);
        Set<String> roleAuthority = syUserMapper.getRoleAuthority(account);
        set.addAll(getRole);
        set.addAll(deptAuthority);
        set.addAll(roleAuthority);
        map.put("permissions",set);
        map.put("user",list1);
        map.put("allPermissions",list);
        map.put("deptAuthority",deptAuthority);
        return map;
    }
    /**
     * @Description  权限设置
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public int addRoleData(Integer value,Boolean boo,Integer userId) {
        //获取该用户与改权限的角色关联
        List<Map<String,Object>> addRoleDataId= personnelDao.addRoleDataId(value,userId);
        //获取该用户与权限的角色关联
        List<Integer> addUseprDataId=personnelDao.addUseprDataId(value,userId);
        int i=0,f=0;
        //如果为true则该权限为选中状态，如果为false则该权限为未选中状态
        if(!boo){
            if(addRoleDataId.size()!=0){
                for(Map<String,Object> m:addRoleDataId){
                    Integer role_id = (Integer) m.get("role_id");
                    Integer id = (Integer) m.get("id");
                    i= personnelDao.delRoleDataId1(role_id);
                    f=personnelDao.delRoleDataId2(id);
                }
            }else if(addUseprDataId.size()!=0){
                for(Integer s:addUseprDataId){
                    i=personnelDao.delUseprDataId(s);
                    if(i!=0){
                        f=1;
                    }

                }
            }
        }else{
             i=personnelDao.addAuthorityData(value,userId,3);
            if(i!=0){
                f=1;
            }
        }
        if(i==0||f==0){
            throw new RuntimeException();
        }
        return i+f;
    }
    /**
     * @Description  获取客服列表数据
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String, Object>> selSmartAI() {
        List<Map<String, Object>> maps = personnelDao.selSmartAI();
        for(int i=0;i<maps.size();i++){
            Integer from_id = (Integer) maps.get(i).get("from_id");
            Integer to_id = (Integer) maps.get(i).get("to_id");
            Map<String, Object> fromName=personnelDao.selSmartAiName(from_id);
            Map<String, Object> toName=personnelDao.selSmartAiName1(to_id);
            if(fromName!=null){
                maps.get(i).putAll(fromName);
            }
            if(toName!=null){
                maps.get(i).putAll(toName);
            }
        }
        return  maps;
    }
    /**
     * @Description  获取客服接待人数
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public Map<String, Integer> selReceptionNum() {
        //获取今天客服接待人数
        int i = personnelDao.selTodayNum();
        //获取客服昨天接待人事
        int i1 = personnelDao.selYesterdayNum();
        //获取客服进30天接待人数
        int i2 = personnelDao.selThirtyDaysNum();
        //获取客服总接待人数
        int i3 = personnelDao.selWholeNum();
        Map<String,Integer> map=new HashMap<>();
        map.put("selTodayNum",i);
        map.put("selYesterdayNum",i1);
        map.put("selThirtyDays",i2);
        map.put("selWholeNum",i3);
        return map;
    }
    /**
     * @Description  删除客服聊天难记录
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public int delSmartAI(Integer id) {
        return personnelDao.delSmartAI(id);
    }
    /**
     * @Description  获取客服列表查看记录数据
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public List<Map<String,Object>> selRecord(Integer id) {
        List<Map<String, Object>> map=null;
        List<Map<String,Object>> strings = personnelDao.selRecord(id);
        for(int a=0;a<strings.size();a++){
            Integer from_id = (Integer) strings.get(a).get("from_id");
            Integer to_id = (Integer) strings.get(a).get("to_id");
            map = personnelDao.selRecordList(from_id, to_id);
            for(int i=0;i<map.size();i++){
                Integer fromId = (Integer) map.get(i).get("from_id");
                Integer toId = (Integer) map.get(i).get("to_id");
                Map<String,Object> fromName=personnelDao.selSmartAiName(fromId);
                Map<String,Object> toName=personnelDao.selSmartAiName1(toId);
                if(fromName!=null){
                    map.get(i).putAll(fromName);
                }
                if(toName!=null){
                    map.get(i).putAll(toName);
                }
            }
        }
        return map;
    }
    /**
     * @Description  获取当前客服的接待记录
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    @Override
    public Map<String,Object> selReception(Integer id) {
        //获取今天客服接待记录
        List<Map<String, Object>> i = personnelDao.selToday(id);
        List<Map<String, Object>> userData = getUserData(i);
        //获取客服昨天接待记录
        List<Map<String, Object>> i1 = personnelDao.selYesterday(id);
        List<Map<String, Object>> userData1 = getUserData(i1);
        //获取客服进30天接待记录
        List<Map<String, Object>> i2 = personnelDao.selThirtyDays(id);
        List<Map<String, Object>> userData2 = getUserData(i2);
        //获取客服总接待记录
        List<Map<String, Object>> i3 = personnelDao.selWhole(id);
        List<Map<String, Object>> userData3 = getUserData(i3);
        Map<String,Object> map=new HashMap<>();
        map.put("selToday",userData);
        map.put("selYesterday",userData1);
        map.put("selThirtyDays",userData2);
        map.put("selWhole",userData3);
        return map;
    }
    /**
     * @Description 通过id获取前台用户信息
     * @return java.util.List<si.yun.entity.PerCourseLook>
     * @Date 2021/9/10 19:08
     **/
    public List<Map<String,Object>> getUserData(List<Map<String, Object>> list){
        for(int i=0;i<list.size();i++){
            Integer from_id = (Integer) list.get(i).get("from_id");
            Integer to_id = (Integer) list.get(i).get("to_id");
            Map<String,Object> fromIdList=personnelDao.getUserData(from_id);
            list.get(i).putAll(fromIdList);
            Map<String,Object> toIdList=personnelDao.getUserData1(to_id);
            list.get(i).putAll(toIdList);
        }
        return list;
    }
    /**
     * @Description  查询搜索统计量
     * @return java.util.List<si.yun.entity.SySearch>
     * @Date 2021/9/11 11:54
     **/
    @Override
    public List<SySearch> selSearchNums() {
        List<SySearch> sySearches = personnelDao.selSearchNums();
        return sySearches;
    }

 /**
     * @Description  查询导航栏消息总数
     * @return java.util.List<si.yun.entity.SySearch>
     * @Date 2021/9/11 11:54
     **/
    @Override
    public int selSumTips() {
        int status = SyProductMapper.getStatisticalAuditStatus(2);
        int secstatus = dao.Secstatus();
        return status+secstatus;
    }

    /*
     * @Description : 根据指定时间，查询不同类型下的课程视频收藏量
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/11/30 9:59
     */
    @Override
    public List<Map<String,Object>> selCourseCollection2(String date) {
        List<Map<String,Object>> perCourseLooks = personnelDao.selCourseCollection2(date);
        return perCourseLooks;
    }

    /*
     * @Description : 根据指定时间，查询不同类型下的微圈商品收藏量统计
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/11/30 10:43
     */
    @Override
    public List<Map<String, Object>> selCommodityCollection2(String date) {
        List<Map<String,Object>> perCourseLooks = personnelDao.selCommodityCollection2(date);
        return perCourseLooks;
    }

    /*
     * @Description : 根据指定时间，查询不同类型下的微圈收藏量
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/11/30 11:02
     */
    @Override
    public List<Map<String, Object>> selMicrocircleCollection2(String date) {
        List<Map<String,Object>> perCourseLooks = personnelDao.selMicrocircleCollection2(date);
        return perCourseLooks;
    }

    /*
     * @Description : 根据指定时间，查询不同类型下的课程视频点赞量
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/11/30 11:38
     */
    @Override
    public List<Map<String,Object>> selCoursePraise2(String date) {
        List<Map<String,Object>> perCourseLooks = personnelDao.selCoursePraise2(date);
        return perCourseLooks;
    }

    /*
     * @Description : 根据指定时间，查询不同类型下的商品点赞量统计
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/11/30 11:55
     */
    @Override
    public List<Map<String, Object>> selProductLikes2(String date) {
        List<Map<String,Object>> perCourseLooks = personnelDao.selProductLikes2(date);
        return perCourseLooks;
    }


    /*
     * @Description : 根据指定时间，查询不同类型下的微圈点赞量
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/11/30 13:36
     */
    @Override
    public List<Map<String, Object>> selMicroCirclePraise2(String date) {
        List<Map<String,Object>> perCourseLooks = personnelDao.selMicroCirclePraise2(date);
        return perCourseLooks;
    }

    /*
     * @Description : 用户观看视频
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/12/1 14:10
     */
    @Override
    public List<Map<String, Object>> selUserVideo2(Integer userId) {
        List<Map<String, Object>> list = personnelDao.selUserVideo2(userId);
        return list;
    }

    /*
     * @Description : 用户收藏
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/12/6 9:09
     */
    @Override
    public List<Map<String, Object>> selCollectionCourse(Integer userId,Integer type) {
        List<Map<String, Object>> list = personnelDao.selCollectionCourse(userId,type);
        return list;
    }

    /*
     * @Description : 用户收藏商品
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/12/6 9:59
     */
    @Override
    public List<Map<String, Object>> selCollectionProduct(Integer userId, Integer type) {
        List<Map<String, Object>> list = personnelDao.selCollectionProduct(userId, type);
        return list;
    }

    /*
     * @Description : 用户收藏微圈
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/12/6 10:25
     */
    @Override
    public List<Map<String, Object>> selCollectionForum(Integer userId, Integer type) {
        List<Map<String, Object>> list = personnelDao.selCollectionForum(userId, type);
        return list;
    }

    /*
     * @Description : 用户点赞课程
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/12/6 10:53
     */
    @Override
    public List<Map<String, Object>> selLikeCourse(Integer userId, Integer type) {
        List<Map<String, Object>> list = personnelDao.selLikeCourse(userId, type);
        return list;
    }

    /*
     * @Description : 用户点赞商品
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/12/6 11:06
     */
    @Override
    public List<Map<String, Object>> selLikeProduct(Integer userId, Integer type) {
        List<Map<String, Object>> list = personnelDao.selLikeProduct(userId, type);
        return list;
    }

    /*
     * @Description : 用户点赞微圈
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/12/6 11:25
     */
    @Override
    public List<Map<String, Object>> selLikeForum(Integer userId, Integer type) {
        List<Map<String, Object>> list = personnelDao.selLikeForum(userId, type);
        return list;
    }

    /*
     * @Description : 查询用户账号
     * @Return : java.util.List<java.lang.Integer>
     * @Date : 2021/12/17 15:46
     */
    @Override
    public  List<Map<String,Object>> selAccount() {
        List<Map<String,Object>> list = personnelDao.selAccount();
        return list;
    }




    /**
     *  @Decriptron 版本查询
     * @Date:2021/12/27 11:26
     * @Return:java.util.List<java.util.Map<java.lang.Object,java.lang.Object>>
     */
    @Override
    public List<Map<Object, Object>> SelVerion(Integer VersionCode,String createDate,String createUser) {
        List<Map<Object, Object>> maps = personnelDao.SelVerion(VersionCode,createDate,createUser);
        return maps;
    }

    /**
     *  @Decriptron 版本详细信息
     * @Date:2021/12/27 20:46
     * @Return:java.util.List<java.util.Map<java.lang.Object,java.lang.Object>>
     */
    @Override
    public List<Map<Object, Object>> queryVersion(Integer id) {
        List<Map<Object, Object>> maps = personnelDao.queryVersion(id);
        return maps;
    }

    /**
     *  @Decriptron 添加版本
     * @Date:2021/12/28 11:58
     * @Return:int
     */
    @Override
    public int AddVersion(Map<String, Object> map) {
        int AddVersion = personnelDao.AddVersion(map);
        return AddVersion;
    }







}

